package com.example.java.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.java.Entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User>{
    //    查询所有
    @Select("select * from user")
    List<User> alluser();

    //    增加或修改
    @Insert("INSERT into user(id,name,pay,username,password,balance) VALUES (#{id},#{name},#{pay},#{username},#{password},#{balance})")
    int insert(User user);

    @Insert("update user set name = #{name}, pay = #{pay}, username = #{username}, password = #{password}, balance = #{balance} where id = #{id}")
    int updata(User user);

    //    通过id删除
    @Delete("delete from user where id = #{id}")
    Integer deleteById(@Param("id") Integer id);

    //    名字模糊查询
    @Select("select * from `user` where name like concat('%',#{name},'%')")
    List<User> getLike(String name);

}
